<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/page/inc/taglib.jsp"%>
<link rel="stylesheet" href="${pageContext.request.contextPath}/statics/ztree/css/zTreeStyle/zTreeStyle.css"
      type="text/css">
<div class="pageContent">
	<form method="post" action="${pageContext.request.contextPath}${requestScope.record ==null ?'/investment/customer/insert' :'/investment/customer/update' }" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
		<div class="pageFormContent" layoutH="56">
			<!-- 关闭窗口 -->
			<input type="hidden" name="callbackType" value="closeCurrent" />
			<!-- 隐藏表单 -->
			<c:if test="${requestScope.record !=null}">
				<input type="hidden" name="id" value="${requestScope.record.id}" />
			</c:if>
			<p>
				<label>客户名称</label> <input name="name" class="required" maxlength="50" type="text" value="${requestScope.record.name}" />
			</p>
			<p>
				<label>日期</label> <input name="date" class="required date" maxlength="50" type="text" value="<fmt:formatDate value="${requestScope.record.date}" pattern="yyyy-MM-dd" />" />
			</p>
			<p>
				<label>时间</label> <input name="time" class="required date" maxlength="50" type="text" value="<fmt:formatDate value="${requestScope.record.time}" pattern="yyyy-MM-dd" />" />
			</p>
			<p>
				<label>电话</label> <input name="phone" class="required phone" maxlength="50" type="text" value="${requestScope.record.phone}" />
			</p>
			<p>
				<label>其他联系方式</label> <input name="other" class="required phone" maxlength="50" type="text" value="${requestScope.record.other}" />
			</p>
			<p>
				<label>跟进人</label> 
				<select name="maid" class="combox required">
					<c:forEach items="${requestScope.maids }" var="maid">
						<option value="${maid.employeeId }">${maid.employeeName }</option>
					</c:forEach>
				</select>
			</p>
			<div id="areas_pcr">
				<label>地区</label>
						<div id="combox_2674245" class="select" ref="w_combox_city">
							<select id="getProvince" class="combox"  ref="w_combox_city" refurl="${pageContext.request.contextPath}/system/areas/getCityByProvince" style="">
								<option value="all">所有省市</option>
								<c:forEach items="${requestScope.provinces}" var="province">
									<option value="${province.id}" ${province.name==areaNames[0]?'selected="selected"':''}>${province.name}</option>
								</c:forEach> 
							</select>
						</div>
						<div id="combox_w_combox_city" class="select" ref="w_combox_region">
							<select id="getCity" class="combox"  id="w_combox_city" ref="w_combox_region" refurl="demo/combox/region_{value}.html" style="">
								<option value="all">所有城市</option>
								<c:forEach items="${requestScope.citys }" var="city">
									<option value="${city.id}" ${city.name==areaNames[1]?'selected="selected"':''}>${city.name}</option>
								</c:forEach>
							</select>
						</div>
						<div id="combox_w_combox_region" class="select">
							<select id="getRegion" class="combox"  id="w_combox_region" style="">
								<option value="all">所有区县</option>
									<c:forEach items="${requestScope.regions }" var="region">
									<option value="${region.id}" ${region.name==areaNames[2]?'selected="selected"':''}>${region.name}</option>
								</c:forEach>
							</select>
						</div>
						<p></p>
				<p>
					<label>地区编号</label> <input id="areaCode_"  readonly="readonly"   name="areaCode" class="required" maxlength="50" type="text" value="${requestScope.record.areaCode}" />
				</p>
			</div>
			<p>
				<label>客户来源</label> <input name="source" class="required" maxlength="50" type="text" value="${requestScope.record.source}" />
			</p>
			<p>
				<label>客户状态</label> 
				 <input type="radio" name="state" value="1" checked="checked" ${requestScope.record.state==1 ? 'checked="checked"' :'' } />未联系 
				 <input type="radio" name="state" value="2" ${requestScope.record.state==2 ? 'checked="checked"' :'' } />跟进中
			</p>
			<p>
				<label>客户意向</label> 
				<select name="intent" class="combox required">
					<option ${requestScope.record.intent==null ? 'selected="selected"' :'' }>--请选择--</option>
					<option value="A"  ${requestScope.record.intent=="A" ? 'selected="selected"' :'' }>A</option>
					<option value="B"  ${requestScope.record.intent=="B" ? 'selected="selected"' :'' }>B</option>
					<option value="C"  ${requestScope.record.intent=="C" ? 'selected="selected"' :'' }>C</option>
					<option value="D"  ${requestScope.record.intent=="D" ? 'selected="selected"' :'' }>D</option>
					<option value="E"  ${requestScope.record.intent=="E" ? 'selected="selected"' :'' }>E</option>
				</select>
			</p>
			<p>
				<label>性别</label> 
				<input type="radio" name="sex" value="1" checked="checked" ${requestScope.record.sex==1 ? 'checked="checked"' :'' } />男 <input type="radio" name="sex" value="2" ${requestScope.record.sex==2 ? 'checked="checked"' :'' } />女
			</p>
			
			<p>
				<label>招商类型</label> <input name="type" class="" maxlength="50" type="text" value="${requestScope.record.type}" />
			</p>
			<p>
				<label>备注1</label> <input name="remk1" class="" maxlength="50" type="text" value="${requestScope.record.remk1}" />
			</p>
			<p>
				<label>备注2</label> <input name="remk2" class="" maxlength="50" type="text" value="${requestScope.record.remk2}" />
			</p>
			<p>
				<label>备注3</label> <input name="remk3" class="" maxlength="50" type="text" value="${requestScope.record.remk3}" />
			</p>
			<p>
				<label>备注4</label> <input name="remk4" class="" maxlength="50" type="text" value="${requestScope.record.remk4}" />
			</p>
			<p>
				<label>备注5</label> <input name="remk5" class="" maxlength="50" type="text" value="${requestScope.record.remk5}" />
			</p>
			<p>
				<input type="hidden" name="areaName" value="" id="setAreaName">
			</p>
		</div>
		<div class="formBar">
			<ul>
				<!--<li><a class="buttonActive" href="javascript:;"><span>保存</span></a></li>-->
				<li><div class="buttonActive">
						<div class="buttonContent">
							<button type="submit">保存</button>
						</div>
					</div></li>
				<li>
					<div class="button">
						<div class="buttonContent">
							<button type="button" class="close">取消</button>
						</div>
					</div>
				</li>
			</ul>
		</div>
	</form>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath}/statics/ztree/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/statics/ztree/js/jquery.ztree.excheck.js"></script>
 
<script>
/*
 * 省市联动
 */
	$("#getProvince").change(function(){
		$("#getCity").html('<option value="">所有省市</option>');
		$.ajax({
			url:'${pageContext.request.contextPath}/system/areas/getCityByProvince?id='+$(this).val(),
			dataType:'JSON',
			success:function(result1){
				/* var optStr = "";
				for(ct of result){
					if(ct[0].substring(2,6)!="0000"){
						optStr += '<option value="'+ct[0]+'">'+ct[1]+'</option>';
					}
				}
				$("#getCity").append($(optStr)); */
				$("#getCity").comboxRefresh(result1);
				
				$("#getRegion").html('<option value="">请选择</option>');
				$.ajax({
					url:'${pageContext.request.contextPath}/system/areas/getCountyByAreas?id='+$("#getCity").val(),
					dataType:'JSON',
					success:function(result2){
						/* var optStr1 = "";
						for(ct of result){
							if(ct[0].substring(4,6)!="00"){
								optStr1 += '<option value="'+ct[0]+'">'+ct[1]+'</option>';
							}
						}
						$("#getRegion").append($(optStr1)); */
						$("#getRegion").comboxRefresh(result2);
						setAreaName();
					}
				});
				
			}
		})
		
	})
	
/*
 * 市区联动
 */
	$("#getCity").change(function(){
		$("#getRegion").html('<option value="">请选择</option>');
		$.ajax({
			url:'${pageContext.request.contextPath}/system/areas/getCountyByAreas?id='+$(this).val(),
			dataType:'JSON',
			success:function(result3){
				/* var optStr = "";
				for(ct of result){
					optStr += '<option value="'+ct[0]+'">'+ct[1]+'</option>';
				}
				$("#getRegion").append($(optStr)); */
				$("#getRegion").comboxRefresh(result3);
			}
		})
		setAreaName();
	})
	
	$("#getRegion").change(function(){
		setAreaName();
	})
	
	
	function setAreaName(){
		var pN = $("#getProvince option:selected").text();
		var cN = $("#getCity option:selected").text();
		var rN = $("#getRegion option:selected").text();
		var final_ = pN+","+cN+","+rN;
		console.log(final_);
		$("#setAreaName").attr("value",final_);
		$("#areaCode_").text($("#getRegion option:selected").val());
		$("#areaCode_").attr("value",$("#getRegion option:selected").val());
	}
	
	
</script>
